﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Doo_JetDAL;
using DoodJetView.Core;

namespace DoodJetView.VuesPartielles
{
    /// <summary>
    /// Logique d'interaction pour EmployerForm_BrevetPermis.xaml
    /// </summary>
    public partial class EmployerForm_employe : UserControl
    {
        //private MainWindow mainWindow;
        private Employes.EtapesEmployes etapesEmployes;

        public Doo_JetDAL.employes employer { get; set; }

        public EmployerForm_employe(Employes.EtapesEmployes etapesEmployes)
        {
            InitializeComponent();
            // TODO: Complete member initialization
            this.etapesEmployes = etapesEmployes;
        }


        private void btn_Submit_Click(object sender, RoutedEventArgs e)
        {
            this.etapesEmployes.ContentUsers.Children.Clear();
            this.etapesEmployes.ContentUsers.Children.Add(
                    this.etapesEmployes.Etape2);
        }

        public void SaveEmployer() {

            using (DataEntities db = new DataEntities())
            {
                this.employer = new employes
                {
                    nomEmploye = txtb_nom.Text,
                    prenomEmploye = txtb_prenom.Text,
                    numSecu = txtb_numSecu.Text,
                    DateVisiteMed = DateTimeUnixTools.ConvertToUnixTimestamp((DateTime)datePicker_DateVisiteMedical.SelectedDate),
                };
                db.employes.AddObject(this.employer);

                db.SaveChanges();

            }
        }

    }
}
